package com.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blog.entity.Notification;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface NotificationMapper extends BaseMapper<Notification> {
    
    /**
     * 获取用户未读通知数量
     */
    @Select("SELECT COUNT(*) FROM notification WHERE user_id = #{userId} AND status = 0")
    Integer selectUnreadCount(Long userId);
    
    /**
     * 将用户所有通知标记为已读
     */
    @Update("UPDATE notification SET status = 1 WHERE user_id = #{userId} AND status = 0")
    Integer markAllAsRead(Long userId);
} 